import 'package:flutter/material.dart';

class StatusTagWidget extends StatelessWidget {
  final String text;
  final TextStyle style;
  final double borderRadius;
  final Color? color;
  final EdgeInsets padding;

  const StatusTagWidget({
    Key? key,
    required this.text,
    this.style = const TextStyle(
      fontSize: 8,
      fontWeight: FontWeight.w500,
      color: Colors.white,
    ),
    this.borderRadius = 2.0,
    this.color,
    this.padding = const EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return IntrinsicHeight(
      child: IntrinsicWidth(
        child: Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(borderRadius),
            color: color ?? Theme.of(context).primaryColor,
          ),
          padding: padding,
          child: Center(child: Text(text, style: style)),
        ),
      ),
    );
  }
}

class OutlinedStatusTagWidget extends StatelessWidget {
  final String text;
  final TextStyle? style;
  final double borderRadius;
  final Color? color;
  final EdgeInsets padding;

  const OutlinedStatusTagWidget({
    Key? key,
    required this.text,
    this.style,
    this.borderRadius = 2.0,
    this.color,
    this.padding = const EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final c = color ?? Theme.of(context).primaryColor;
    return IntrinsicHeight(
      child: IntrinsicWidth(
        child: Container(
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(borderRadius),
            border: Border.all(color: c),
          ),
          padding: padding,
          child: Center(
            child: Text(
              text,
              style: style ??
                  Theme.of(context).textTheme.caption?.copyWith(color: c),
            ),
          ),
        ),
      ),
    );
  }
}

class OutlineTagWidget extends StatelessWidget {
  final String text;
  final double borderRadius;
  final Color? color;
  final double fontSize;
  final FontWeight fontWeight;
  final double? height;
  final double? width;

  const OutlineTagWidget({
    Key? key,
    required this.text,
    this.borderRadius = 2.0,
    this.color,
    this.fontSize = 10.0,
    this.fontWeight = FontWeight.w500,
    this.height = 18.0,
    this.width = 40.0,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final c = color ?? Theme.of(context).primaryColor;
    return SizedBox(
      height: height,
      width: width,
      child: OutlinedButton(
        onPressed: () {},
        style: OutlinedButton.styleFrom(
          side: BorderSide(color: c),
          padding: EdgeInsets.zero,
        ),
        child: Text(
          text,
          style: TextStyle(
            fontWeight: fontWeight,
            fontSize: fontSize,
            color: c,
          ),
        ),
      ),
    );
  }
}
